#pragma once

#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <string>
#include <clocale>
#include <algorithm>
#include <vector>
#include <array>
#include "forward_list.h"
#include "interest_table.h"
#include "person.h"
#include "couple.h"
#include "person_list.h"
#include "couples_list.h"
#include "dating.h"

using namespace std;

void test(){
	/*
	interest_table it1;
	interest_table it2("datorspel");
	string interests[] = { "spinning", "logdans", "matlagning" };
	interest_table it3(interests, 3);
	cout << it2.value_at_position(0) << endl;
	it1 = it2;
	it2.clear();
	cout << it1.value_at_position(0) << endl;
	cout << it3.value_at_position(0) << endl;
	cout << it3.value_at_position(1) << endl;

	cout << endl << endl;

	person person1("jeppe",it3);
	cout << person1.get_name() << endl;
	it2 = person1.get_table();
	cout << it2.value_at_position(0) << endl;
	cout << it2.value_at_position(1) << endl;

	cout << endl << endl;

	person person2("veronica", "matlagning");
	couple couple1(person1,person2);
	cout << couple1.get_boy().get_name() << endl;
	cout << couple1.get_girl().get_name() << endl;

	cout << endl << endl;

	person_list boys1(person1);
	person_list girls1(person2);
	cout << boys1.value_at_position(0).get_name() << endl;
	cout << girls1.value_at_position(0).get_name() << endl;

	cout << endl << endl;

	couples_list couples_list1;
	couples_list1.insert_couple(couple1);
	person person3("anders", "matlagning");
	person person4("anna", "matlagning");
	couple couple2(person3, person4);
	couples_list1.insert_couple(couple2);

	cout << couples_list1.value_at_position(0).get_girl().get_name() << endl;
	cout << couples_list1.value_at_position(1).get_girl().get_name() << endl;

	cout << endl << endl;

	person person5("kalle", "matlagning");
	person person6("karin", "spinning");
	couple couple3(person5, person6);
	couples_list1.insert_couple(couple3);

	person person7("lars", "matlagning");
	person person8("lisa", "matlagning");
	couple couple4(person7, person8);
	couples_list1.insert_couple(couple4);

	person person9("xerxes", "matlagning");
	person person10("xena", "matlagning");
	couple couple5(person9, person10);
	couples_list1.insert_couple(couple5);

	cout << couples_list1.value_at_position(0).get_girl().get_name() << endl;
	cout << couples_list1.value_at_position(1).get_girl().get_name() << endl;
	cout << couples_list1.value_at_position(2).get_girl().get_name() << endl;
	cout << couples_list1.value_at_position(3).get_girl().get_name() << endl;
	cout << couples_list1.value_at_position(4).get_girl().get_name() << endl;

	person_list boys2(person1);
	person_list girls2(person2);
	boys2.push_front(person3);
	girls2.push_front(person4);
	boys2.push_front(person5);
	girls2.push_front(person6);
	boys2.push_front(person7);
	girls2.push_front(person8);
	boys2.push_front(person9);
	girls2.push_front(person10);

	dating d1(boys2,girls2);
	d1.generate_couples_unique(1);
	d1.print_couples();

	cout << endl;

	d1.print_boys();
	d1.print_girls();

	cout << endl;
	cout << endl;

	person_list pl_f;
	pl_f.readFromFile("temp.txt");
	for (int i = 0; i < pl_f.size(); ++i){
	cout << pl_f.value_at_position(i).get_name() << endl;
	for (int j = 0; j < pl_f.value_at_position(i).get_table().size(); ++j){
	cout << "   " << pl_f.value_at_position(i).get_table().value_at_position(j) << endl;
	}
	}

	cout << endl;
	cout << endl;

	person_list boys3, girls3;
	boys3.readFromFile("boys.txt");
	girls3.readFromFile("girls.txt");
	dating d2(boys3, girls3);
	d2.generate_couples_unique(2);
	d2.print_couples();
	*/
}


int main(){


	person_list boys_list, girls_list;
	boys_list.readFromFile("boys.txt");
	girls_list.readFromFile("girls.txt");
	dating my_dating(boys_list, girls_list);

	string  input = "";
	int no_interests = -1;

	cout << "Dejtprogram" << endl << endl;
	
	while (no_interests < 0) {
		cout << "Ange antal gemensamma intressen: ";
		getline(cin, input);
		istringstream iss(input);
		iss >> no_interests;
	}

	while (!(input == "j" || input == "ja" || input == "Ja" || input == "JA" || 
		input == "n" || input == "nej" || input == "Nej" || input == "NEJ")) {
		cout << "Ska paren vara unika (j/n): ";
		getline(cin, input);
	}

	if (input == "j" || input == "ja" || input == "Ja" || input == "JA"){
		my_dating.generate_couples_unique(no_interests);
	}
	else if (input == "n" || input == "nej" || input == "Nej" || input == "NEJ"){
		my_dating.generate_couples(no_interests);
	}

	cout << "Genererade par:" << endl << endl;
	my_dating.print_couples();

	cout << endl;

	system("pause");
	return 0;
}